using System;
using System.Drawing;
using System.Runtime.InteropServices;
using PickGold.Charting;

namespace PickGold.Charting.ChartTypes
{
	internal class PyramidChart : FunnelChart
	{
		public PyramidChart()
		{
			base.isPyramid = true;
			base.round3DShape = false;
			base.funnelLabelStyleAttributeName = "PyramidLabelStyle";
			base.funnelPointGapAttributeName = "PyramidPointGap";
			base.funnelRotationAngleAttributeName = "Pyramid3DRotationAngle";
			base.funnelPointMinHeight = "PyramidMinPointHeight";
			base.funnel3DDrawingStyleAttributeName = "Pyramid3DDrawingStyle";
			base.funnelInsideLabelAlignmentAttributeName = "PyramidInsideLabelAlignment";
			base.funnelOutsideLabelPlacementAttributeName = "PyramidOutsideLabelPlacement";
		}

		protected override void GetPointWidthAndHeight(Series series, int pointIndex, float location, out float height, out float startWidth, out float endWidth)
		{
			PointF empty = PointF.Empty;
			RectangleF absoluteRectangle = base.Graph.GetAbsoluteRectangle(base.PlotAreaPosition);
			float num = absoluteRectangle.Height - (base.funnelSegmentGap * (base.pointNumber - (this.ShouldDrawFirstPoint() ? 1 : 2)));
			if (num < 0f)
			{
				num = 0f;
			}
			height = (float)(num * (this.GetYValue(series.Points[pointIndex], pointIndex) / base.yValueTotal));
			height = base.CheckMinHeight(height);
			PointF tf2 = ChartGraphics.GetLinesIntersection(absoluteRectangle.X, location - height, absoluteRectangle.Right, location - height, absoluteRectangle.X, absoluteRectangle.Bottom, absoluteRectangle.X + (absoluteRectangle.Width / 2f), absoluteRectangle.Y);
			if (tf2.X > (absoluteRectangle.X + (absoluteRectangle.Width / 2f)))
			{
				tf2.X = absoluteRectangle.X + (absoluteRectangle.Width / 2f);
			}
			PointF tf3 = ChartGraphics.GetLinesIntersection(absoluteRectangle.X, location, absoluteRectangle.Right, location, absoluteRectangle.X, absoluteRectangle.Bottom, absoluteRectangle.X + (absoluteRectangle.Width / 2f), absoluteRectangle.Y);
			if (tf3.X > (absoluteRectangle.X + (absoluteRectangle.Width / 2f)))
			{
				tf3.X = absoluteRectangle.X + (absoluteRectangle.Width / 2f);
			}
			startWidth = Math.Abs((float)((absoluteRectangle.X + (absoluteRectangle.Width / 2f)) - tf2.X)) * 2f;
			endWidth = Math.Abs((float)((absoluteRectangle.X + (absoluteRectangle.Width / 2f)) - tf3.X)) * 2f;
			empty = new PointF(absoluteRectangle.X + (absoluteRectangle.Width / 2f), location - (height / 2f));
			series.Points[pointIndex].positionRel = base.Graph.GetRelativePoint(empty);
		}

		public override string Name
		{
			get
			{
				return "Pyramid";
			}
		}
	}
}

